<template>
  <button :class="$style['launch-btn']" :disabled="loading">
    <!-- <IconLoading v-if="loading" class="mr-6px inline-block" /> -->
    <span>
      <slot />
    </span>
    <div v-if="loading" :class="$style.loading"></div>
  </button>
</template>

<script
  lang="ts"
  setup
  name="RoundedBtn"
>
defineProps({
  loading: {
    type: Boolean,
    default: false
  }
})
</script>

<style module lang="scss">
.launch-btn {
  @apply relative;
  padding: 0 40px;
  height: 36.5px;
  font-size: 16.5px;
  font-weight: 600;
  color: #33395a;
  letter-spacing: 1px;

  >* {
    position: relative;
    z-index: 3;
  }

  &::before,
  &::after {
    content: '';
    @apply block absolute top-0 left-0 z-1;
    border-radius: 25px;
    transition: right 0.2s, bottom 0.2s;
  }

  &::before {
    right: 3px;
    bottom: 3px;
    background: linear-gradient(138.87deg, #e8f1ff00 35.14%, #c4d0e1cc 76.63%, #ffffffcc 125.31%);
  }

  &::after {
    z-index: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(138.87deg, rgba(255, 255, 255, 0.85) 0%, rgba(196, 208, 225, 0.6666666667) 40%, rgba(196, 208, 225, 0.8) 90%, rgba(255, 255, 255, 0.85) 125.31%);
  }

  &:active {
    &::before {
      right: 1px;
      bottom: 1px;
    }
  }
}

@keyframes shimmer {
  to {
    background-position: -50% 0;
  }
}

.loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  border-radius: 25px;
  background-image: linear-gradient(-60deg,
      rgba(0, 0, 0, 0) 0px,
      rgb(229 229 229 / 60%) 40px,
      rgba(0, 0, 0, 0) 80px);
  background-size: 300%;
  background-position: 0% 0;
  animation: shimmer 1.5s infinite;
}
</style>
